package com.ruoyi.hr.service.impl.welfare.tsgjj;

import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.hr.domain.Authority;
import com.ruoyi.hr.domain.welfare.tsgjj.Tsgjj;
import com.ruoyi.hr.mapper.welfare.tsgjj.TsgjjMapper;
import com.ruoyi.hr.service.welfare.tsgjj.TsgjjService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service
public class TsgjjServiceImpl implements TsgjjService {

    @Autowired
    private TsgjjMapper tsgjjMapper;

    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public List<Tsgjj> findTsgjj(Tsgjj tsgjj, List<Authority> authorities, int isAdmin) {
        return tsgjjMapper.findTsgjj(tsgjj, authorities, isAdmin);
    }

    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public Tsgjj findTsgjjById(int id) {
        return tsgjjMapper.findTsgjjById(id);
    }

    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public Map<String, Object> findEmpInfo(String badge) {
        return tsgjjMapper.findEmpInfo(badge);
    }

    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int insertTsgjj(Tsgjj tsgjj) {
        return tsgjjMapper.insertTsgjj(tsgjj);
    }

    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int updateTsgjj(Tsgjj tsgjj) {
        return tsgjjMapper.updateTsgjj(tsgjj);
    }

    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int deleteTsgjjByIds(String ids) {
        int num = 0;
        String[] array = ids.split(",");
        for (String id : array) {
            num += tsgjjMapper.deleteTsgjjById(id);
        }
        return num;
    }
}
